#include <iostream>
using namespace std;

int month[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main()
{
	int y, m, d; cin >> y >> m >> d;

	int cnt = 0;
	for (int i = 0; i < m - 1; ++i)
	{
		cnt += month[i];
	}
	cnt += d;

	if (m > 2 && ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0))
	{
		cnt += 1;
	}

	cout << cnt << endl;
	return 0;
}